#ifndef _MW_PROCESS_CYCLE_H_INCLUDED_
#define _MW_PROCESS_CYCLE_H_INCLUDED_

#include <stdint.h>
#include <signal.h>

#include "mw_config.h"
#include "mw_core.h"
#include "mw_process.h"
#include "mw_cycle.h"

#define MW_CMD_OPEN_CHANNEL   1
#define MW_CMD_CLOSE_CHANNEL  2
#define MW_CMD_QUIT           3
#define MW_CMD_TERMINATE      4
#define MW_CMD_REOPEN         5


#define MW_PROCESS_SINGLE     0
#define MW_PROCESS_MASTER     1
#define MW_PROCESS_SIGNALLER  2
#define MW_PROCESS_WORKER     3
#define MW_PROCESS_HELPER     4

void mw_master_process_cycle(int num_prcesses, worker_main_fn worker_main, worker_exit_fn worker_exit, void* data);
void mw_single_process_cycle();
void mw_set_callback(const std::string& name, const MasterEvent& event);


extern uint32_t        mw_process;
extern pid_t           mw_pid;
extern pid_t           mw_new_binary;
extern uint32_t        mw_inherited;
extern uint32_t        mw_daemonized;
extern uint32_t        mw_threaded;
extern uint32_t        mw_exiting;

extern sig_atomic_t    mw_reap;
extern sig_atomic_t    mw_sigio;
extern sig_atomic_t    mw_sigalrm;
extern sig_atomic_t    mw_quit;
extern sig_atomic_t    mw_debug_quit;
extern sig_atomic_t    mw_terminate;
extern sig_atomic_t    mw_noaccept;
extern sig_atomic_t    mw_reconfigure;
extern sig_atomic_t    mw_reopen;
extern sig_atomic_t    mw_change_binary;


#endif /* _MW_PROCESS_CYCLE_H_INCLUDED_ */
